package com.aaa.service;


import com.aaa.entity.Admin;
import com.aaa.mapper.AdminMapper;


import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import java.util.List;
import java.util.Map;

@Service
public class AdminService {
    @Resource
    AdminMapper adminMapper ;
     @Resource
    HttpSession session;
    public Integer login(String uname,String password){
        List<Map<String, Object>> list =  adminMapper.selectName(uname,password);
        if(list.size()==0){
            // 没有查询到用户信息
            return 0;
        }else if(list.size()>0){
            // 用户名密码正确
            session.setAttribute("loginUser", list.get(0));
            return 1;
        }
        else {
            //用户异常
            return  2;
        }
    }
    //注册
    public int add(Admin admin){
        return adminMapper.insert(admin);
    }

}
